package com.blog.admin.controller;

import com.blog.admin.service.BlogClassifyService;
import com.blog.admin.vo.BlogClassifyVO;
import com.blog.vo.PageVO;
import com.blog.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tangqj
 * @Description
 * @create 2020/2/18 15:14
 */
@RestController
@RequestMapping("blogClassifyController")
public class BlogClassifyController {
    @Autowired
    BlogClassifyService blogClassifyService;


    @RequestMapping("getBlogClassify")
    public Map<String,Object> getBlogClassify(PageVO page,BlogClassifyVO blogClassifyVO){
        PageInfo<BlogClassifyVO> result = blogClassifyService.getBlogClassify(page,blogClassifyVO);
        Map<String,Object> data = new HashMap<>();
        data.put("count", result.getTotal());
        return Result.responeAjaxMap(true,"", result.getList(),data);
    }

    @RequestMapping("insertBlogClassify")
    public Map<String,Object> insertBlogClassify(BlogClassifyVO blogClassifyVO){
        boolean result = blogClassifyService.insertBlogClassify(blogClassifyVO);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }

    @RequestMapping("updateBlogClassify")
    public Map<String,Object> updateBlogClassify(BlogClassifyVO blogClassifyVO){
        boolean result = blogClassifyService.updateBlogClassify(blogClassifyVO);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }

    @RequestMapping("deleteBlogClassifyById")
    public Map<String,Object> deleteBlogClassifyById(String id){
        boolean result = blogClassifyService.deleteBlogClassifyById(id);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }
}
